<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <div>这是div1</div>
    <div>这是div2</div>
    <p>这是段落 1</p>
    <p>这是段落 2</p>
    <script>
        var t = document.querySelectorAll;
        var arr = [];

        arr.push.apply(arr, t.apply(document, ['div']));
        arr.push.apply(arr, t.apply(document, ['p']));

        console.log(arr);
        for (var i = 0; i < arr.length; i++) {
            arr[i].style.border = '1px solid #f00'
        }
    </script>
</body>

</html>